import pywencai

def query_wencai(query, loop=True):
    # loop表示返回几页股票，值为True时返回所有股票
    df = pywencai.get(query=query, sort_key='股票代码', sort_order='asc', loop=loop)

    if df is None:
        return None
    elif df.empty:
        return None
    else:
        return df.to_json(orient='records', force_ascii=False)